#ifndef NETWORKDIALOG_H
#define NETWORKDIALOG_H
#include <QDialog>
#include <QTcpServer>
#include <QTcpSocket>

namespace Ui {
class NetworkDialog;
}

class NetworkDialog : public QDialog
{
    Q_OBJECT

public:
    explicit NetworkDialog(QWidget *parent = nullptr);
    ~NetworkDialog();

private slots:
    void on_modeComboBox_currentIndexChanged(int index);
    void on_connectButton_clicked();
    void on_sendButton_clicked();

    // 网络事件处理
    void onNewConnection();
    void onClientConnected();
    void onReadyRead();
    void onDisconnected();

private:
    Ui::NetworkDialog *ui;
    QTcpServer *m_server;
    QTcpSocket *m_socket;
    bool m_isConnected;

    void setupConnections();
    void updateUI();
};

#endif // NETWORKDIALOG_H
